home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / DDPLUS71.ZIP / COMIO.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-01  |  7KB  |  277 lines

  1.  
  2. unit comio;
  3. {$V-,S-,R-}
  4.  
  5. interface
  6.  
  7. uses ddfossil, async2, ddigi;
  8. type
  9.  AsyncIoTypes=(Fossil,Internal,Bios,Digi);
  10. var
  11.  AsyncIoType: AsyncIotypes;
  12.  initok, NoFossinit, fosBnu  : boolean;
  13.  internalinsize,internaloutsize: word;
  14.  
  15. procedure AsyncSelectPort(pn: byte);
  16. procedure AsyncSendChar(ch: char);
  17. procedure AsyncReceiveChar(var ch: char);
  18. function  AsyncCarrierPresent: boolean;
  19. function  AsyncCharPresent: boolean;
  20. procedure AsyncSelectFossil(var fossilname:string);
  21. procedure AsyncSelectInternal;
  22. procedure AsyncSelectDigiBoard(var digiboardname:string);
  23. procedure AsyncCloseUp;
  24. procedure AsyncCloseCom(cp : byte);
  25. procedure AsyncSetBaud(n: longint);
  26. procedure AsyncSetDTR(state: boolean);
  27. procedure AsyncFlushOutput;
  28. procedure AsyncPurgeOutput;
  29. procedure AsyncSetFlow(SoftTran,Hard,SoftRecv: boolean);
  30. Procedure AsyncBufferStatus(var Insize,infree,outsize,outfree: word;
  31.                             var fossilname:string);
  32. Procedure SetUpPorts;
  33. Procedure LoadPorts  (var port1,port2,port3,port4: word;
  34.                       var irq1,irq2,irq3,irq4 : byte);
  35. Procedure ResetPorts (var port1,port2,port3,port4: word;
  36.                       var irq1,irq2,irq3,irq4 : byte);
  37.  
  38.  
  39. implementation
  40.  
  41. procedure AsyncSelectPort(pn: byte);
  42. begin;
  43.  comport:=pn;
  44.  case AsyncIoType of
  45.    Fossil: begin
  46.              port_num:=pn-1;
  47.              If NoFossInit then
  48.                begin
  49.                  async_purge_output;      { 10/29/94 SRL This may clear up}
  50.                  async_purge_input;       {a problem xfoss had Ripdetect. }
  51.                  initok:=true;
  52.                end
  53.              else
  54.                begin
  55.                  async_deinit_fossil;
  56.                  initok:=async_init_fossil;
  57.                end;
  58.             end;
  59.   Internal: begin;
  60.              closeallcoms;
  61.              initok:=opencom(pn,InternalInSize,InternalOutSize);
  62.             end;
  63.   Digi    : begin
  64.               dport_num:=pn-1;
  65.               initok:=digi_init_driver;
  66.             end;
  67.  end;
  68. end;
  69.  
  70. procedure AsyncSendChar(ch: char);
  71. begin;
  72.  case AsyncIoType of
  73.   Fossil  : async_send(ch);
  74.   Internal: begin
  75.               While CTSStat(comport) or RTSstat(comport) do
  76.                 If Not AsyncCarrierPresent then exit;
  77.               ComWriteChw(comport,ch);
  78.             end;
  79.   Digi    : begin
  80.               While (Not OutReady) do
  81.                if Not AsyncCarrierPresent then exit;
  82.               Digi_send(ch);
  83.             end;
  84.  end;
  85. end;
  86.  
  87. procedure AsyncReceiveChar(var ch: char);
  88. var
  89.  b: boolean;
  90. begin;
  91.  case asyncIotype of
  92.   Fossil  : b:=async_receive(ch);
  93.   Internal: ch:=ComReadCh(comport);
  94.   Digi    : b:=digi_receive(ch);
  95.  end;
  96. end;
  97.  
  98. function AsyncCarrierPresent: boolean;
  99. begin;
  100.  case asyncIoType of
  101.   Fossil  : AsyncCarrierPresent:=async_carrier_present;
  102.   Internal: AsyncCarrierPresent:=DCDStat(comport);
  103.   Digi    : AsyncCarrierPresent:=digi_carrier_present;
  104.  end;
  105. end;
  106.  
  107. function AsyncCharPresent: boolean;
  108. begin;
  109.  case asyncIoTYpe of
  110.   Fossil  : asyncCharPresent:=Async_buffer_check;
  111.   Internal: asynccharpresent:=combufferleft(comport,'I')<>c_insize[comport];
  112.   Digi    : asyncCharPresent:=Digi_buffer_check;
  113.  end;
  114. end;
  115.  
  116. procedure AsyncSelectFossil;
  117. var
  118.   Insize,infree,outsize,outfree: word;
  119.   s:string;
  120.   p:byte;
  121. begin;
  122.  AsyncIoType:=Fossil;
  123.  AsyncBufferStatus(Insize,infree,outsize,outfree,fossilname);
  124.  s:='';
  125.  for p:=1 to length(fossilname) do
  126.   s:=s+Upcase(fossilname[p]);
  127.  p:=Pos('BNU',s);
  128.  if p>0 then fosbnu:=true;
  129. end;
  130.  
  131. procedure AsyncSelectDigiBoard;
  132. var
  133.   Insize,infree,outsize,outfree: word;
  134. begin;
  135.  AsyncIoType:=Digi;
  136.  digi_Get_Info(digiboardname);
  137. end;
  138.  
  139. procedure AsyncCloseUp;
  140. begin;
  141.  case AsyncIoType of
  142.   Fossil  : Async_deinit_fossil;
  143.   Internal: closeallcoms;
  144.   Digi    : Digi_deinit_driver;
  145.  end;
  146. end;
  147.  
  148. procedure AsyncCloseCom;
  149. begin;
  150.  case AsyncIoType of
  151.   Fossil  : Async_deinit_fossil;
  152.   Internal: closecom(cp);
  153.   Digi    : Digi_deinit_driver;
  154.  end;
  155. end;
  156.  
  157. procedure AsyncSetBaud(n: longint);
  158. var
  159.  i:byte;
  160. begin;
  161.  case asynciotype of
  162.   Fossil  : If not NoFossInit then
  163.               If fosbnu then
  164.                 async_set_baudbnu(n)
  165.               else
  166.                 async_set_baud(n);
  167.   Internal: comparams(comport,n,8,'N',1);
  168.   Digi    : begin
  169. {             initok:=digi_set_baud(n,8,'N',1);}
  170.               digi_flush_io;
  171.              end;
  172.  
  173.  end;
  174. end;
  175.  
  176. procedure AsyncSelectInternal;
  177. begin;
  178.  AsyncIOType:=Internal;
  179. end;
  180.  
  181. procedure AsyncSetDTR(state: boolean);
  182. begin;
  183.  case AsyncIOType of
  184.   Fossil:   async_set_dtr(state);
  185.   Internal: SetDTR(comport,state);
  186.  end;
  187. end;
  188.  
  189. procedure AsyncFlushOutput;
  190. begin;
  191.  case AsyncIOType of
  192.   Fossil  : async_flush_output;
  193.   Internal: ComWaitForClear(comport);
  194.   Digi    : digi_flush_output;
  195.  end;
  196. end;
  197.  
  198. procedure AsyncPurgeOutput;
  199. begin;
  200.  case AsyncIOType of
  201.   Fossil  : async_purge_output;
  202.   Internal: ClearCom(comport,'O');
  203.   Digi    : digi_flush_output;
  204.  end;
  205. end;
  206.  
  207. procedure AsyncSetFlow(SoftTran,Hard,SoftRecv: boolean);
  208. begin;
  209.  {*srl}
  210.  case AsyncIOType of
  211.   Fossil:   async_set_flow(softtran,hard,softrecv);
  212.   Internal: begin;
  213.               SetCTSMode(comport,hard);
  214.               SetRTSMode(comport,hard,C_RTSOn[comport],C_RTSOff[comport]);
  215.               SoftHandShake(comport,softtran,'A','A');
  216.              end;
  217.  end;
  218. end;
  219.  
  220. Procedure AsyncBufferStatus(var Insize,infree,outsize,outfree: word;
  221.                             var fossilname:string);
  222. begin;
  223.   case asynciotype of
  224.     Fossil: async_buffer_Status(insize,infree,outsize,outfree,fossilname);
  225.     Internal: begin;
  226.              insize:=internalinsize;
  227.              outsize:=internaloutsize;
  228.              infree:=combufferleft(comport,'I');
  229.              outfree:=combufferleft(comport,'O');
  230.             end;
  231.  end;
  232. end;
  233.  
  234. Procedure SetUpPorts;
  235. var
  236.   i : byte;
  237. begin
  238.  for i := 1 to 4 do
  239.     begin
  240.       C_PortAddr[i] := D_PortAddr[i];
  241.       C_PortInt[i]  := D_PortInt[i];
  242.     end;
  243. end;
  244.  
  245. Procedure LoadPorts (var port1,port2,port3,port4: word;
  246.                      var irq1,irq2,irq3,irq4 : byte);
  247. begin
  248.  port1 :=  D_PortAddr[1];
  249.  irq1  :=  D_PortInt[1];
  250.  port2 :=  D_PortAddr[2];
  251.  irq2  :=  D_PortInt[2];
  252.  port3 :=  D_PortAddr[3];
  253.  irq3  :=  D_PortInt[3];
  254.  port4 :=  D_PortAddr[4];
  255.  irq4  :=  D_PortInt[4];
  256. end;
  257.  
  258. Procedure ResetPorts (var port1,port2,port3,port4: word;
  259.                       var irq1,irq2,irq3,irq4 : byte);
  260. begin
  261.   C_PortAddr[1] := port1;
  262.   C_PortInt[1]  := irq1;
  263.   C_PortAddr[2] := port2;
  264.   C_PortInt[2]  := irq2;
  265.   C_PortAddr[3] := port3;
  266.   C_PortInt[3]  := irq3;
  267.   C_PortAddr[4] := port4;
  268.   C_PortInt[4]  := irq4;
  269. end;
  270.  
  271. begin;
  272.  AsyncIoType:=Internal;
  273.  comport:=1;
  274.  internalinsize :=2048;
  275.  internaloutsize:=2048;
  276. end.
  277.